﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace PatientInformationExtract.Converter
{
    public class BooleanConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string boolean = (string)value;
            switch (boolean)
            {
                case "True":
                    {
                        return true;
                    }
                case "False":
                    {
                        return false;
                    }
                default:
                    {
                        throw new Exception("Value is not validated.");
                    }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool boolean = (bool)value;
            if (boolean)
            {
                return "True";
            }
            else
            {
                return "False";
            }
        }
    }
}
